<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="continor">
        <input type="text" id="input">
        <button onclick="send()">发送</button>
    </div>

    <script>
        // Create WebSocket connection.
        const socket = new WebSocket('ws://localhost:3000/conectWs');

        // Connection opened
        socket.addEventListener('open', function (event) {
            socket.send('Hello Server!');
        });

        // Listen for messages
        socket.addEventListener('message', function (event) {
            console.log('Message from server ', event.data);
        });
        function send(){
            const inputObj=document.getElementById('input');
            socket.send(inputObj.value)
        }
    </script>
</body>

</html>